#!/bin/bash

createday=`date -d '40 day' '+%Y%m'`
createquery="CREATE TABLE vc_hist_data_$createday (
  seq bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  socialid varchar(32) NOT NULL,
  uuid varchar(64) NOT NULL,
  phone_number varchar(64) NOT NULL,
  company int(3) NOT NULL COMMENT '마켓',
  sale_cd int(11) NOT NULL COMMENT '매출코드',
  app_ver varchar(10) NOT NULL COMMENT '어플버전',
  lv_stage varchar(20) NOT NULL COMMENT '레벨_스테이지',
  slot_number int(11) NOT NULL COMMENT '슬롯번호',
  ref_vc_division1 int(11) NOT NULL COMMENT '대분류',
  ref_vc_division2 int(11) NOT NULL COMMENT '중분류',
  ref_vc_division3 int(11) NOT NULL COMMENT '소분류',
  ref_vc_desc varchar(20) NOT NULL COMMENT 'vc설명',
  ref_unit_price int(11) NOT NULL COMMENT '단가',
  unit_count int(11) NOT NULL COMMENT '사용개수',
  chg_amount int(11) NOT NULL COMMENT '변동량 (단가*수량)',
  cur_vc_kind int(3) NOT NULL COMMENT '현재 사용할 vc종류( 0:vc1 1:vc2 2:vc3 ), 최대 3종류까지 사용 가능',
  cur_vc1 int(11) NOT NULL COMMENT '현재 캐쉬1',
  cur_vc2 int(11) NOT NULL COMMENT '현재 캐쉬2',
  cur_vc3 int(11) NOT NULL COMMENT '현재 캐쉬3',
  reg_date datetime NOT NULL,
  PRIMARY KEY (seq)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"

#echo $createquery
mysql -ugamevil -pvlwlrpaqlf pz_user -e "$createquery"
